//
//  discoverSmallCell.m
//  Focus
//
//  Created by xwc on 14-11-4.
//  Copyright (c) 2014年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "discoverSmallCell.h"

@implementation discoverSmallCell
-(void)dealloc{
    [super dealloc];
    [_titleLable release];
    [_fromLable release];
}
- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        UILabel *titleLable = [[UILabel alloc] init];
        self.titleLable = titleLable;
        self.titleLable.font = [UIFont systemFontOfSize:16];
        [titleLable release];
        self.titleLable.numberOfLines = 0;
        [self.titleLable sizeToFit];
        [self.contentView addSubview:self.titleLable];
        
        UILabel *fromLable = [[UILabel alloc] init];
        self.fromLable = fromLable;
        self.fromLable.font = [UIFont systemFontOfSize:14];
        self.fromLable.textColor = [UIColor grayColor];
        [fromLable release];
        [self.contentView addSubview:self.fromLable];
        
        
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    self.titleLable.frame = CGRectMake(0, 0, self.contentView.frame.size.width, self.contentView.frame.size.height / 3 * 2);
    self.fromLable.frame = CGRectMake(0, self.contentView.frame.size.height / 3 * 2, self.contentView.frame.size.width, self.contentView.frame.size.height / 3);
}

- (void)setDiscoverModel:(discoverTitleModel *)discoverModel
{
    if (_discoverModel != nil) {
        [_discoverModel release];
        _discoverModel = [discoverModel retain];
    }
    self.titleLable.frame = CGRectMake(0, 0, self.contentView.frame.size.width, self.contentView.frame.size.height / 3 * 2);
    self.fromLable.frame = CGRectMake(0, self.contentView.frame.size.height / 3 * 2, self.contentView.frame.size.width, self.contentView.frame.size.height / 3);
    
    if (discoverModel.location == 2) {
        self.titleLable.text = discoverModel.titleStr1;
        self.fromLable.text = discoverModel.fromStr1;
    } else if (discoverModel.location == 3) {
        self.titleLable.text = discoverModel.titleStr2;
        self.fromLable.text = discoverModel.fromStr2;
    } else if (discoverModel.location == 4) {
        self.titleLable.text = discoverModel.titleStr3;
        self.fromLable.text = discoverModel.fromStr3;
    } else if (discoverModel.location == 5) {
        self.titleLable.text = discoverModel.titleStr4;
        self.fromLable.text = discoverModel.fromStr4;
    } else if (discoverModel.location == 6) {
        self.titleLable.text = discoverModel.titleStr5;
        self.fromLable.text = discoverModel.fromStr5;
    }
    
}

/*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.
 - (void)drawRect:(CGRect)rect
 {
 // Drawing code
 }
 */

@end
